package org.ouwh.oowiki.http;

import org.ouwh.oowiki.ctrl.ErrorCodes;

public class MyException extends Exception {
	private static final long serialVersionUID = -5458201948214226512L;

	private int errCode;

	public MyException(int errCode, String message) {
		super(message);
		this.errCode = errCode;
	}
	
	public MyException(ErrorCodes err) {
		super(err.getMsg());
		this.errCode = err.getCode();
	}

	public MyException(int errCode, String message, Throwable cause) {
		super(message, cause);
		this.errCode = errCode;
	}

	public MyException(String strErrCode, String message) {
		super(message);
		try {
			this.errCode = Integer.parseInt(strErrCode);
		} catch (NumberFormatException e) {
			this.errCode = -100;
		}
	}

	public MyException(String strErrCode, String message, Throwable cause) {
		super(message, cause);
		try {
			this.errCode = Integer.parseInt(strErrCode);
		} catch (NumberFormatException e) {
			this.errCode = -100;
		}
	}

	public int getErrorCode() {
		return errCode;
	}

	@Override
	public String getMessage() {
		return super.getMessage() + ", errorCode: " + errCode;
	}

}
